//===============================================================================
// Copyright (C) 2008 Charles River Media. All rights reserved.
// 
// Catmull-Clark subdivision surface viewer program
//
// The developer of the code is
// Gyorgy Antal <gyantal@gmail.com>
//
// Contributor(s):
// Laszlo Szirmay-Kalos <szirmay@iit.bme.hu>
//
// The software was developed for the chapter 
// "Fast Evaluation of Subdivision Surfaces on DirectX10 Graphics Hardware"
// of the book ShaderX 6: Advanced Rendering Techniques, 
// edited by Wolfgang Engel,
// the appropriate section edited by Tom Forsyth. 
//
// The files are provided without support, instruction, or implied warranty of any
// kind.  Charles River Media makes no guarantee of its fitness for a particular purpose and is
// not liable under any circumstances for any damages or loss whatsoever arising
// from the use or inability to use this file or items derived from it.
//
// The source code can be found in the RenderVista project: 
// http://code.google.com/p/rendervista/source
// More specifically on this site:
// http://rendervista.googlecode.com/svn/trunk/Projects/DX10Subdivision/
//===============================================================================
// File: Scene.h
//
// Description:
//===============================================================================


#include <D3D10.h>
#include <d3dx10.h>

#define MaxVertCount 32768 
#define MaxTexUvCount 32768 
#define MaxNormalCount 32768 
#define MaxTangentCount 32768 
#define MaxQuadCount 32768 

//--------------------------------------------------------------------------------------
// Structures
//--------------------------------------------------------------------------------------
struct SimpleVertex
{
	D3DXVECTOR3 Pos; 
	//unsigned int Valence;
};


struct SimplePointVertex
{
	UINT Index;  
};

struct Quad
{
	int VertIndex0;
	int VertIndex1;
	int VertIndex2;
	int VertIndex3;
};

struct QuadAdjacency
{
	int QuadIndex0;
	int QuadIndex1;
	int QuadIndex2;
	int QuadIndex3;
};

struct QuadTextureInd
{
	int TexIndex0;
	int TexIndex1;
	int TexIndex2;
	int TexIndex3;
};

struct QuadNormalInd
{
	int NormalIndex0;
	int NormalIndex1;
	int NormalIndex2;
	int NormalIndex3;
};

struct QuadTangentInd
{
	int TangentIndex0;
	int TangentIndex1;
	int TangentIndex2;
	int TangentIndex3;
};

class Scene
{
	int g_nVerts;
	SimpleVertex g_vertices[MaxVertCount];

};


SCENE_EXTERN int g_nVerts;
SCENE_EXTERN SimpleVertex g_vertices[MaxVertCount];
SCENE_EXTERN unsigned int g_vertValences[MaxVertCount];

SCENE_EXTERN int g_nTextureUvs;
SCENE_EXTERN D3DXVECTOR2 g_textureUvs[MaxTexUvCount];

SCENE_EXTERN int g_nNormals;
SCENE_EXTERN D3DXVECTOR3 g_normals[MaxNormalCount];

SCENE_EXTERN int g_nTangents;
SCENE_EXTERN D3DXVECTOR3 g_tangents[MaxTangentCount];

SCENE_EXTERN int g_nQuads;
SCENE_EXTERN Quad g_quads[MaxQuadCount];
//SCENE_EXTERN QuadAdjacency g_quadAdjacencys[MaxQuadCount];
SCENE_EXTERN int g_quadAdjacentVerticesInd[20 * MaxQuadCount];
SCENE_EXTERN QuadTextureInd g_quadTextureInd[MaxQuadCount];
SCENE_EXTERN QuadNormalInd g_quadNormalInd[MaxQuadCount];
SCENE_EXTERN QuadTangentInd g_quadTangentInd[MaxQuadCount];

HRESULT SCENE_EXTERN LoadModelData_OBJ(char* p_fullPath);